package com.spring.learn;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

/**
 * Created by bgt on 2017/4/23.
 * Spring 初始化启动的方式RedissonClient
 */
public class SpringRunType {
   static BeanFactory factory;
   static ApplicationContext context ;
   static ClassPathXmlApplicationContext context3 ;
    static  void init() {
        ApplicationContext  res = new FileSystemXmlApplicationContext("classpath:application-context.xml");
        factory = res;
    }
    static  void init2() {
        context= new ClassPathXmlApplicationContext(
                new String[] {"application-context.xml"});
        factory = context;
    }
    static  void init3() {
        context3= new ClassPathXmlApplicationContext(
                new String[] {"application-context.xml"});
        factory = context3;
    }
    static  void init4() {
        context3= new ClassPathXmlApplicationContext(
                new String[] {"application-context.xml","application-context-mvc.xml"});
        factory = context3;
    }
    public static void main(String[] args) {

        /*SpringRunType.init2();*/
       // SpringRunType.init3();
        SpringRunType.init3();

        UserBean userBean= (UserBean) factory.getBean("mybean");
        System.out.println(userBean.getAge());
        //context3.close();//销毁方法
    }
}
